package br.com.cardapiolivre.persistencia;

import br.com.cardapiolivre.entidades.Delivery;
import br.com.cardapiolivre.entidades.Entidade;
import java.util.List;
import javax.persistence.Query;

/**
 *
 * @author juan
 */
public class DeliveryDaoJpa extends DaoJpa<Delivery> {

    @Override
    public Delivery consultar(Long id) throws Exception {
         try {
            return (Delivery) em.find(Delivery.class, id);
        } catch (Exception ex) {
            throw ex;
        }
    }

    @Override
    public List<Delivery> consultar() throws Exception {
        try {
            Query q = em.createQuery("SELECT d FROM Delivery d ");
            return q.getResultList();
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new Exception("Erro ao consultar culinária.");
        }
    }
    
    
}
